﻿using AntDesign.JsInterop;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using OneOf;
using SageKing.Database.Contracts;

namespace SageKing.UI.Blazor.SageKingAntDesign.Contracts;

public interface IModal<T>
    where T : ICloneable
{

    /// <summary>
    /// Tab 标题
    /// </summary>
    public string TabTitle { get; set; }

    /// <summary>
    /// 父节点name
    /// </summary>
    public string ParentName { get; set; }

    /// <summary>
    /// Model 标题
    /// </summary>
    public string Title { get; set; }

    /// <summary>
    /// 保存
    /// </summary>
    public OneOf<string, RenderFragment>? OkTitle { get; set; }

    /// <summary>
    /// 取消
    /// </summary>
    public OneOf<string, RenderFragment>? CancelText { get; set; }

    /// <summary>
    /// 是否显示
    /// </summary>
    public bool Visible { get; set; }

    /// <summary>
    /// 加载显示
    /// </summary>
    public bool Loading { get; set; }

    /// <summary>
    /// 当前实体
    /// </summary>
    public T Model { get; set; }

    public Error? Error { get; set; }


    #region 组件操作

    public RenderFragment ModalTemplate { get; set; }
    public  string TemplateName { get; set; }
    public  string TemplateType { get; set; }
    string MaxBodyHeight { get; set; }
    string Class { get; set; }
    string Style { get; set; }
    OneOf<string, double> Width { get; set; }
    bool Draggable { get; set; }
    bool Centered { get; set; }
    bool Closable { get; set; }

    Dictionary<string, object> Properties { get; set; }
     
    public Action StateHasChangedAction { get; set; }

    public Task HandleOk(MouseEventArgs e);
    public Task HandleClose(MouseEventArgs e);
    public Task ResizedChanged(HtmlElement e);


    #endregion

    #region 方法
    public Task EditOnStatusSwitch(T row);
    #endregion
}
